<?php
	if(!defined('__ICOMPARABLE_PHP__'))
	{
		define('__ICOMPARABLE_PHP__', true);
		
		/**
		 * @function A rule for use with usort. Sorts the elements according to their implementations
		 * of the compareTo-method. Both elements must inherit the IComparable interface
		 * 
		 * @return The result of the comparison
		 */
		function compareIComparables(Highscore $a, Highscore $b)
		{
			$result = 0;
			
			if(($a instanceof IComparable) && ($b instanceof IComparable))
			{
				$result = $a->compareTo($b);
			}
			
			return $result;
		}
		
		/**
		 * @interface An interface guarateing the class has a method for comparing
		 */
		interface IComparable
		{
			/**
			 * @method Compares this instance to another instance of this class
			 * 
			 * @param $that the instance to compare this instance to (IComparable)
			 * @return 0 if the two instances are exactly alike, a negative number if this instance
			 * is smaller than the one it's being compared to, and a positive number if this
			 * instance is bigger than the one it's being compared to
			 */
			function compareTo($that);
		}
	}
?>
